package LoginPackage;

import org.testng.annotations.Test;
import PagePackage.MyPageFactory;
import PagePackage.teamsPage;

public class SchoolsSearch extends TestBaseClass {
	
	@Test (priority=0)
	public void AdminSearchSchoolByName() {
	goToMainPage();
	checkPage()
	.loginAs(adminEmail, adminPassword)
	.clickschooltab()
	.findSchoolbyName("Basketball University")
	.clickSearch()
	.scrollAndClickSchool(0, 0, "//*[contains(text(),'Basketball University')]")
	.logout();	
		
	}
	@Test (priority=1)
	public void AdminSearchSchoolByCity() {
	goToMainPage();
	checkPage()
	.loginAs(adminEmail, adminPassword)
	.clickschooltab()
	.findSchoolbyCity("Brooklyn")
	.clickSearch()
	.clickonFirstResult()
	.checkCity("Brooklyn")
		.cancelSchool()
		.logout();
		
	}
	
	@Test (priority=2)
	public void AdminSearchSchoolByState() {
	goToMainPage();
	checkPage()
	.loginAs(adminEmail, adminPassword)
	.clickschooltab()
	.findSchoolbyState("NY")
	.clickSearch()
	.clickonFirstResult()
	 .checkState("NY")
		.cancelSchool()
		.logout();
		
	}
	
	@Test (priority=3)
	public void AdminSearchSchoolByCountry() {
	goToMainPage();
	checkPage()
	.loginAs(adminEmail, adminPassword)
	.clickschooltab()
	.findSchoolbyCountry("US")
	.clickSearch()
	.clickonFirstResult()
	 .checkCountry("US")
		.cancelSchool()
		.logout();
		
	}
	
	@Test (priority=4)
	public void AdminSearchSchoolByConference() {
	goToMainPage();
	checkPage()
	.loginAs(adminEmail, adminPassword)
	.clickschooltab()
	.findSchoolbyConference("Big 12")
	.clickSearch()
	.clickonFirstResult()
	 .checkConference("Big 12")
		.cancelSchool()
		.logout();
		
	}
	
	@Test (priority=5)
	public void AdminSearchSchoolByNameCityStateCountryConference() {
	goToMainPage();
	checkPage()
	.loginAs(adminEmail, adminPassword)
	.clickschooltab()
	.findSchoolbyName("Texas Tech University")
	.findSchoolbyCity("Lubbock")
	.findSchoolbyState("TX")
	.findSchoolbyConference("Big 12")
	.clickSearch()
	.clickonFirstResult()
	.checkCity("Lubbock")
	.checkState("TX")
	 .checkConference("Big 12")
		.cancelSchool()
		.logout();
}
	
	@Test (priority=6)
	public void AdminSearchSchoolNoResults() {
	goToMainPage();
	checkPage()
	.loginAs(adminEmail, adminPassword)
	.clickschooltab()
	.findSchoolbyName("No results found")
	.clickSearch();
	MyPageFactory.getPage(driver, teamsPage.class).noResults()
	
		.logout();
}
	@Test (priority=7)
	public void SASearchSchoolByName() {
	goToMainPage();
	checkPage()
	.loginAs(saEmail, saPassword)
	.clickschooltab()
	.findSchoolbyName("Basketball University")
	.clickSearch()
	.scrollAndClickSchool(0, 0, "//*[contains(text(),'Basketball University')]")
	.logout();	
		
	}
	@Test (priority=8)
	public void SASearchSchoolByCity() {
	goToMainPage();
	checkPage()
	.loginAs(saEmail, saPassword)
	.clickschooltab()
	.findSchoolbyCity("Brooklyn")
	.clickSearch()
	.clickonFirstResult()
	.checkCity("Brooklyn")
		.cancelSchool()
		.logout();
		
	}
	
	@Test (priority=9)
	public void SASearchSchoolByState() {
	goToMainPage();
	checkPage()
	.loginAs(saEmail, saPassword)
	.clickschooltab()
	.findSchoolbyState("NY")
	.clickSearch()
	.clickonFirstResult()
	 .checkState("NY")
		.cancelSchool()
		.logout();
		
	}
	
	@Test (priority=10)
	public void SASearchSchoolByCountry() {
	goToMainPage();
	checkPage()
	.loginAs(saEmail, saPassword)
	.clickschooltab()
	.findSchoolbyCountry("US")
	.clickSearch()
	.clickonFirstResult()
	 .checkCountry("US")
		.cancelSchool()
		.logout();
		
	}
	
	@Test (priority=11)
	public void SASearchSchoolByConference() {
	goToMainPage();
	checkPage()
	.loginAs(saEmail, saPassword)
	.clickschooltab()
	.findSchoolbyConference("Big 12")
	.clickSearch()
	.clickonFirstResult()
	 .checkConference("Big 12")
		.cancelSchool()
		.logout();
		
	}
	
	@Test (priority=12)
	public void SASearchSchoolByNameCityStateCountryConference() {
	goToMainPage();
	checkPage()
	.loginAs(saEmail, saPassword)
	.clickschooltab()
	.findSchoolbyName("Texas Tech University")
	.findSchoolbyCity("Lubbock")
	.findSchoolbyState("TX")
	.findSchoolbyConference("Big 12")
	.clickSearch()
	.clickonFirstResult()
	.checkCity("Lubbock")
	.checkState("TX")
	 .checkConference("Big 12")
		.cancelSchool()
		.logout();
}
	
	@Test (priority=13)
	public void SASearchSchoolNoResults() {
	goToMainPage();
	checkPage()
	.loginAs(saEmail, saPassword)
	.clickschooltab()
	.findSchoolbyName("No results found")
	.clickSearch();
	MyPageFactory.getPage(driver, teamsPage.class).noResults()
	
		.logout();
}
}
